IProducerConsumerCollection(T).TryAdd Method

Task Parallel System.Threading

Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Private Function TryAdd ( _
	item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
C#
bool IProducerConsumerCollection<T>.TryAdd(
	T item
)

Parameters

item
Type: T
The object to add to the IProducerConsumerCollection<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

Return Value

true if the object was added successfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd(T)

Remarks

For ConcurrentStack<(Of <(T>)>), this operation will always insert the object onto the top of the ConcurrentStack<(Of <(T>)>) and return true.

See Also